package com.bing.controller.util;

import com.bing.utils.IdeaKeyGen;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by kaibb on 16-1-5.
 */
@Controller
@RequestMapping("util/keyGen")
public class KeyGen {
    private static final Logger LOGGER = LoggerFactory.getLogger(KeyGen.class);
    public static final String PRE = "util/keyGen";

    @RequestMapping("idea")
    @ResponseBody
    public String ideaKey(@RequestParam("name") String name) {
        LOGGER.info("生成Idea key:{}", name);
        return IdeaKeyGen.gen(name);
    }

    @RequestMapping("idea/{name}")
    @ResponseBody
    public String ideaKeyForPathVariable(@PathVariable("name") String name) {
        return ideaKey(name);
    }

    @RequestMapping("ideas")
    public String indexIdea() {
        return PRE + "/idea";
    }
}
